#!/usr/bin/env python3
"""
S31-BSIM: Side-Channel Attack Framework
Setup script for package installation
"""

from setuptools import setup, find_packages
from pathlib import Path

# Read README for long description
readme_file = Path(__file__).parent / "README.md"
long_description = readme_file.read_text(encoding="utf-8") if readme_file.exists() else ""

# Read requirements
requirements_file = Path(__file__).parent / "requirements.txt"
requirements = []
if requirements_file.exists():
    with open(requirements_file, 'r', encoding='utf-8') as f:
        for line in f:
            line = line.strip()
            # Skip comments and empty lines
            if line and not line.startswith('#'):
                # Remove inline comments
                package = line.split('#')[0].strip()
                if package:
                    requirements.append(package)

setup(
    name="s31-bsim",
    version="1.0.0",
    author="gA4ss (Wenbin Yan)",
    author_email="wenbin.yan@colorado.edu",
    description="A comprehensive side-channel attack framework for cryptographic algorithm analysis",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/yourusername/s31-bsim",
    packages=find_packages(exclude=["tests", "tests.*", "examples", "examples.*"]),
    classifiers=[
        "Development Status :: 4 - Beta",
        "Intended Audience :: Science/Research",
        "Intended Audience :: Education",
        "Topic :: Security :: Cryptography",
        "Topic :: Scientific/Engineering",
        "License :: OSI Approved :: Apache Software License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Operating System :: OS Independent",
    ],
    python_requires=">=3.8",
    install_requires=requirements,
    extras_require={
        "dev": [
            "pytest>=6.2.0",
            "pytest-cov>=2.12.0",
            "black>=21.0",
            "flake8>=3.9.0",
            "mypy>=0.900",
        ],
        "advanced": [
            "statsmodels>=0.13.0",
            "seaborn>=0.11.0",
            "dtaidistance>=2.3.0",
        ],
    },
    entry_points={
        "console_scripts": [
            "s31-collect=collect_firmware_traces:main",
            "s31-preprocess=preprocess_traces:main",
            "s31-analyze=analyze_firmware_traces:main",
            "s31-download=download_real_traces:main",
            "s31-experiment=run_experiment:main",
            "s31-report=generate_experiment_report:main",
        ],
    },
    include_package_data=True,
    zip_safe=False,
    keywords=[
        "side-channel attack",
        "power analysis",
        "cryptography",
        "CPA",
        "DPA",
        "SPA",
        "template attack",
        "AES",
        "SM4",
        "RSA",
        "ECC",
        "post-quantum cryptography",
    ],
    project_urls={
        "Bug Reports": "https://github.com/yourusername/s31-bsim/issues",
        "Source": "https://github.com/yourusername/s31-bsim",
        "Documentation": "https://github.com/yourusername/s31-bsim/blob/main/README.md",
    },
)

